///*
// * Tencent is pleased to support the open source community by making wechat-matrix available.
// * Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
// * Licensed under the BSD 3-Clause License (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// *      https://opensource.org/licenses/BSD-3-Clause
// *
// * Unless required by applicable law or agreed to in writing,
// * software distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.example.myapplication;
//
//import android.app.Application;
//import android.content.Context;
//import android.content.Intent;
//
//import com.example.myapplication.config.DynamicConfigImplDemo;
//import com.example.myapplication.listener.TestPluginListener;
//import com.tencent.matrix.Matrix;
//import com.tencent.matrix.iocanary.IOCanaryPlugin;
//import com.tencent.matrix.iocanary.config.IOConfig;
//import com.tencent.matrix.resource.ResourcePlugin;
//import com.tencent.matrix.resource.config.ResourceConfig;
//import com.tencent.matrix.trace.TracePlugin;
//import com.tencent.matrix.trace.config.TraceConfig;
//import com.tencent.matrix.util.MatrixLog;
//import com.tencent.sqlitelint.SQLiteLint;
//import com.tencent.sqlitelint.SQLiteLintPlugin;
//import com.tencent.sqlitelint.config.SQLiteLintConfig;
//
///**
// * Created by caichongyang on 17/5/18.
// */
//
//public class MatrixApplication extends Application {
//    private static final String TAG = "Matrix.Application";
//
//    private static Context sContext;
//
//    private static SQLiteLintConfig initSQLiteLintConfig() {
//        try {
//            /**
//             * HOOK模式下，SQLiteLint会自己去获取所有已执行的sql语句及其耗时(by hooking sqlite3_profile)
//             * @see 而另一个模式：SQLiteLint.SqlExecutionCallbackMode.CUSTOM_NOTIFY , 则需要调用 {@link SQLiteLint#notifySqlExecution(String, String, int)}来通知
//             * SQLiteLint 需要分析的、已执行的sql语句及其耗时
//             * @see TestSQLiteLintActivity#doTest()
//             */
//            return new SQLiteLintConfig(SQLiteLint.SqlExecutionCallbackMode.HOOK);
//        } catch (Throwable t) {
//            return new SQLiteLintConfig(SQLiteLint.SqlExecutionCallbackMode.HOOK);
//        }
//    }
//
//    @Override
//    public void onCreate() {
//        super.onCreate();
//        DynamicConfigImplDemo dynamicConfig = new DynamicConfigImplDemo();
//        boolean matrixEnable = dynamicConfig.isMatrixEnable();
//        boolean fpsEnable = dynamicConfig.isFPSEnable();
//        boolean traceEnable = dynamicConfig.isTraceEnable();
//
//        sContext = this;
//        MatrixLog.i(TAG, "MatrixApplication.onCreate");
//
//        Matrix.Builder builder = new Matrix.Builder(this);
//        builder.patchListener(new TestPluginListener(this));
//
//        //trace
//        TraceConfig traceConfig = new TraceConfig.Builder()
//                .dynamicConfig(dynamicConfig)
//                .enableFPS(fpsEnable)
//                .enableEvilMethodTrace(traceEnable)
//                .enableAnrTrace(traceEnable)
//                .enableStartup(traceEnable)
//                .splashActivities("sample.tencent.matrix.SplashActivity;")
//                .isDebug(true)
//                .isDevEnv(false)
//                .build();
//
//        TracePlugin tracePlugin = (new TracePlugin(traceConfig));
//        builder.plugin(tracePlugin);
//
//        if (matrixEnable) {
//
//            //resource
//            Intent intent = new Intent();
//            ResourceConfig.DumpMode mode = ResourceConfig.DumpMode.MANUAL_DUMP;
//            MatrixLog.i(TAG, "Dump Activity Leak Mode=%s", mode);
//            intent.setClassName(this.getPackageName(), "com.tencent.mm.ui.matrix.ManualDumpActivity");
//            ResourceConfig resourceConfig = new ResourceConfig.Builder()
//                    .dynamicConfig(dynamicConfig)
//                    .setAutoDumpHprofMode(mode)
////                .setDetectDebuger(true) //matrix test code
////                    .set(intent)
//                    .setManualDumpTargetActivity(KotlinActivity.class.getName())
//                    .build();
//            builder.plugin(new ResourcePlugin(resourceConfig));
//            ResourcePlugin.activityLeakFixer(this);
//
//            //io
//            IOCanaryPlugin ioCanaryPlugin = new IOCanaryPlugin(new IOConfig.Builder()
//                    .dynamicConfig(dynamicConfig)
//                    .build());
//            builder.plugin(ioCanaryPlugin);
//
//
//            // prevent api 19 UnsatisfiedLinkError
//            //sqlite
//            SQLiteLintConfig sqlLiteConfig;
//            try {
//                sqlLiteConfig = new SQLiteLintConfig(SQLiteLint.SqlExecutionCallbackMode.CUSTOM_NOTIFY);
//            } catch (Throwable t) {
//                sqlLiteConfig = new SQLiteLintConfig(SQLiteLint.SqlExecutionCallbackMode.CUSTOM_NOTIFY);
//            }
//            builder.plugin(new SQLiteLintPlugin(sqlLiteConfig));
//
////            BatteryMonitorPlugin batteryMonitorPlugin = BatteryCanaryInitHelper.createMonitor();
////            builder.plugin(batteryMonitorPlugin);
//        }
//
//        Matrix.init(builder.build());
//
//        //start only startup tracer, close other tracer.
//        tracePlugin.start();
////        Matrix.with().getPluginByClass(BatteryMonitor.class).start();
//        MatrixLog.i("Matrix.HackCallback", "end:%s", System.currentTimeMillis());
//
//
//    }
//
//    public static Context getContext() {
//        return sContext;
//    }
//}
